<template>
	<div class="home">
		<div>
			<img src="../assets/image/hello.png">
            <p>欢迎来到升学在线</p>
            <a @click="toLink" style="margin-top: 50px;display: inline-block;color: blue;font-size: 20px">跳转到dashboard页面</a>
		</div>
	</div>
</template>
<script>
import api from "@/api";
export default {
  name: "home",
  data(){
    return {
      wxSharePic:'https://static.shengxue985.com/oss/20180830/e5089c21aa9249e0bd121f7a7e21b582.png'
    };
  },
  created(){
   
  },
  mounted(){

  },
  methods:{
    //二次分享
    secondShare(hasData, params) {
      api
        .getSecondShareKey(params)
        .then(res => {
          if (res.data.code == 0) {
            let data = res.data.data;
            wx.config({
              debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
              appId: data.appId, // 必填，公众号的唯一标识
              timestamp: data.timestamp, // 必填，生成签名的时间戳
              nonceStr: data.nonceStr, // 必填，生成签名的随机串
              signature: data.signature, // 必填，签名，见附录1
              jsApiList: [
                "chooseImage",
                "previewImage",
                "uploadImage",
                "downloadImage",
                "checkJsApi",
                "onMenuShareTimeline",
                "onMenuShareAppMessage",
                "onMenuShareQQ",
                "onMenuShareWeibo"
              ] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
            });
            this.wxShare(hasData, {
              title: this.title || "邀您查看话题详情", // 分享标题
              desc: this.content || "升学在线,学习超给力", // 分享描述
              link: window.location.href, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
              imgUrl: this.wxSharePic, // 分享图标
              type: "", // 分享类型,music、video或link，不填默认为link
              dataUrl: "", // 如果type是music或video，则要提供数据链接，默认为空
              success: function() {
                // 用户确认分享后执行的回调函数
              },
              cancel: function() {
                // 用户取消分享后执行的回调函数
              }
            });
          } else {
          }
        })
        .catch(err => {
        });
    },
    wxShare(hasData, config) {
      let c;
      if (!hasData) {
        c = {};
        c.title = "邀您查看话题详情";
        c.desc = "升学在线,学习超给力";
        (c.link = window.location.href), (c.imgUrl = this.wxSharePic);
      } else {
        c = config;
      }
      if (location.hash == "#debug") {
        alert(JSON.stringify(c));
      }
      wx.ready(function() {
        wx.onMenuShareAppMessage(c);
        wx.onMenuShareTimeline(c);
        wx.onMenuShareQQ(c);
        wx.onMenuShareWeibo(c);
      });
    },
    //跳转dashboard页面
    toLink(){
      window.location.href=window.location.origin+"/dashboard-h5"
    }
  }
};
</script>
<style lang="scss">
@import "../styles/mixin.scss";
.home {
  text-align: center;
  img {
      margin-top: px2rem(150);
  }
  p {
    margin-top: px2rem(60);
    font-size: px2rem(50);
  }
}
</style>
